<?php
$http = new swoole_http_server("0.0.0.0", 9501);

$http->on("start", function ($server) {
    echo "Swoole http server is started at http://127.0.0.1:9501\n";
});

$http->set([
	'enable_static_handler' => true,
	'document_root' => '/home/aqie/gits/arithmetic/test/source',
	'worker_num' => 5
]);

/*
$http->on('WorkerStart', function ($serv, $worker_id){
	require __DIR__ . '/index.php';
});
 */

$http->on("request", function ($request, $response) {
	exec(__DIR__."/../output/test.out",$output);
    $response->header("Content-Type", "text/plain");
    // $response->end("Hello Swoole\n");
	$response->cookie('aqie','xss',time()+600);
    $response->end(json_encode($output)."\n");
});

$http->start();
